package com.baizhiedu.beanpost;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

/**
 * 功能：
 * 作者：HZj
 * 日期：2024/12/18 22:36
 */
public class MyBeanPostProcessor implements BeanPostProcessor {
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {

        if (bean instanceof Category) {
            Category category = (Category) bean;
            category.setName("xiaowb");
        }
        return bean;
    }
}
